<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是STM32开发——使用STM32CubeIDE的基本使用的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV16-07-开发工具-02-STM32CubeIDE">
<meta property="og:url" content="https://sumumm.github.io/post/eabbf614.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是STM32开发——使用STM32CubeIDE的基本使用的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520072531092.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520211605992.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520212048180.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520212454737.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520212623949.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520212853055.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520213252022.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520213449227.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520213554845.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520213743159.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520221846123.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520214308701.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520214730034.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520214656757.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520214850663.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520215059445.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520215150914.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520221216688.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520221355783.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520215347548.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520215442928.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520221655244.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520222313154.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520222524117.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520222642043.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520222831189.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520223649493.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520223917430.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520224327480.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520224530746.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521074645330.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521074939885.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521075236576.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521075448244.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521075654220.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521075749284.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521075917133.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521080203882.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521083811134.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521082521120.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521085511731.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521090941592.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521091410734.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521091600745.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521091952504.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521092120050.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521092250347.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521093216174.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521092421567.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520232138219.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521080438832.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521080700527.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520232606339.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520232856040.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520233053740.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520234044989.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521011338146.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521011033549.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521081811404.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521100228974.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521100255053.png">
<meta property="article:published_time" content="2023-06-04T14:06:36.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.007Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="LV16-STM32开发">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520072531092.png">


<link rel="canonical" href="https://sumumm.github.io/post/eabbf614.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://sumumm.github.io/post/eabbf614.html","path":"post/eabbf614.html","title":"LV16-07-开发工具-02-STM32CubeIDE"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV16-07-开发工具-02-STM32CubeIDE | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81STM32CubeIDE%E7%AE%80%E4%BB%8B"><span class="nav-text">一、STM32CubeIDE简介</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%AE%80%E4%BB%8B"><span class="nav-text">1. 简介</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E7%89%B9%E7%82%B9"><span class="nav-text">2. 特点</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81STM32CubeIDE%E5%AE%89%E8%A3%85%E4%B8%8E%E4%BD%BF%E7%94%A8"><span class="nav-text">二、STM32CubeIDE安装与使用</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-Java%E8%BF%90%E8%A1%8C%E7%8E%AF%E5%A2%83"><span class="nav-text">1. Java运行环境</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-STM32CubeIDE%E5%AE%89%E8%A3%85"><span class="nav-text">2. STM32CubeIDE安装</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8"><span class="nav-text">3. 基本使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-STM32CubeIDE%E5%88%9B%E5%BB%BA%E5%B7%A5%E7%A8%8B"><span class="nav-text">3.1 STM32CubeIDE创建工程</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E9%85%8D%E7%BD%AE%E5%A4%96%E8%AE%BE"><span class="nav-text">3.2 配置外设</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-3-%E7%BC%96%E8%AF%91%E4%B8%8E%E4%B8%8B%E8%BD%BD"><span class="nav-text">3.3 编译与下载</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#3-3-1-%E7%BC%96%E8%AF%91%E5%B7%A5%E7%A8%8B"><span class="nav-text">3.3.1 编译工程</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-3-2-%E9%85%8D%E7%BD%AE%E8%B0%83%E8%AF%95%E5%B7%A5%E5%85%B7"><span class="nav-text">3.3.2 配置调试工具</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-3-3-%E4%B8%8B%E8%BD%BD%E7%A8%8B%E5%BA%8F"><span class="nav-text">3.3.3 下载程序</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-4-%E5%AF%BC%E5%85%A5%E8%87%AA%E5%B7%B1%E7%9A%84%E6%96%87%E4%BB%B6"><span class="nav-text">3.4 导入自己的文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-5-%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6"><span class="nav-text">3.5 新建文件</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E7%94%9F%E6%88%90hex%E6%96%87%E4%BB%B6"><span class="nav-text">4. 生成hex文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-Makefile%E6%96%87%E4%BB%B6"><span class="nav-text">5. Makefile文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-%E8%BD%AC%E6%88%90MDK%E5%B7%A5%E7%A8%8B%EF%BC%9F"><span class="nav-text">6. 转成MDK工程？</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81OpenOCD"><span class="nav-text">三、OpenOCD</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%AE%80%E4%BB%8B-1"><span class="nav-text">1. 简介</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E4%B8%8B%E8%BD%BD%E4%B8%8E%E5%AE%89%E8%A3%85"><span class="nav-text">2. 下载与安装</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8-1"><span class="nav-text">3. 基本使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E8%BF%9E%E6%8E%A5%E7%9B%AE%E6%A0%87%E8%8A%AF%E7%89%87"><span class="nav-text">3.1 连接目标芯片</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E8%BF%9E%E6%8E%A5%EF%BC%8B%E4%B8%8B%E8%BD%BD"><span class="nav-text">3.2 连接＋下载</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E6%8A%A5%E9%94%99%E8%A7%A3%E5%86%B3"><span class="nav-text">4. 报错解决</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#4-1-%E6%8A%A5%E9%94%99%E5%8E%9F%E5%9B%A0"><span class="nav-text">4.1 报错原因</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-2-zadig"><span class="nav-text">4.2 zadig </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-3-USBDriverTool"><span class="nav-text">4.3 USBDriverTool </span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%9B%9B%E3%80%81VScode%E6%8F%92%E4%BB%B6%E4%B8%8E%E4%BD%BF%E7%94%A8"><span class="nav-text">四、VScode插件与使用</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E5%AE%89%E8%A3%85%E6%8F%92%E4%BB%B6"><span class="nav-text">1. 安装插件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E5%AF%BC%E5%85%A5%E5%B7%A5%E7%A8%8B"><span class="nav-text">2. 导入工程</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E9%85%8D%E7%BD%AE%E5%B7%A5%E7%A8%8B"><span class="nav-text">3. 配置工程</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E7%BC%96%E8%AF%91%E5%99%A8%E8%B7%AF%E5%BE%84%E9%85%8D%E7%BD%AE"><span class="nav-text">3.1 编译器路径配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-IntelliSense-%E6%A8%A1%E5%BC%8F"><span class="nav-text">3.2 IntelliSense 模式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-3-CMake"><span class="nav-text">3.3 CMake</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E9%85%8D%E5%90%88OpenOCD%E4%B8%80%E9%94%AE%E4%B8%8B%E8%BD%BD"><span class="nav-text">4. 配合OpenOCD一键下载</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-%E8%AF%B4%E6%98%8E"><span class="nav-text">5. 说明</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/eabbf614.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV16-07-开发工具-02-STM32CubeIDE | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV16-07-开发工具-02-STM32CubeIDE
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-06-04 22:06:36" itemprop="dateCreated datePublished" datetime="2023-06-04T22:06:36+08:00">2023-06-04</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/" itemprop="url" rel="index"><span itemprop="name">01HQ课程体系</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">LV16-STM32开发</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>11k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>41 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是STM32开发——使用STM32CubeIDE的基本使用的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" width=150px>Windows</td>        <td align="left">windows11</td>    </tr>    <tr>        <td align="center">Ubuntu</td>        <td align="left">Ubuntu16.04的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 16 Pro</td>        <td align="left">16.2.3 build-19376536</td>      </tr>    <tr>        <td align="center">SecureCRT</td>        <td align="left">Version 8.7.2 (x64 build 2214)   -   正式版-2020年5月14日</td>      </tr>    <tr>        <td align="center">开发板</td>        <td align="left">正点原子 i.MX6ULL Linux阿尔法开发板</td>      </tr>    <tr>        <td align="center">uboot</td>        <td align="left">NXP官方提供的uboot，NXP提供的版本为uboot-imx-rel_imx_4.1.15_2.1.0_ga(使用的uboot版本为U-Boot 2016.03)</td>      </tr>    <tr>        <td align="center">linux内核</td>        <td align="left">linux-4.15(NXP官方提供)</td>      </tr>    <tr>        <td align="center">STM32开发板</td>        <td align="left">正点原子战舰V3(STM32F103ZET6)</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <ul><li>通用</li></ul><table><tr><td align="center">分类  </td><td align="center">网址</td><td align="center">说明</td></tr><tr><td align="center" rowspan="4">官方网站</td><td align="left"><a href="https://www.arm.com/" target="_blank">https://www.arm.com/</a></td><td align="left">ARM官方网站，在这里我们可以找到Cotex-Mx以及ARMVx的一些文档</td></tr><tr>                                            <td align="left"><a href="https://www.st.com/content/st_com/zh.html" target="_blank">https://www.st.com/content/st_com/zh.html</a></td><td align="left">ST官方网站，在这里我们可以找到STM32的相关文档</td></tr><tr>                                            <td align="left"><a href="https://www.stmcu.com.cn/" target="_blank">https://www.stmcu.com.cn/</a></td><td align="left">意法半导体ST中文官方网站，在这里我们可以找到STM32的相关中文参考文档</td></tr><tr>                                            <td align="left"><a href="http://elm-chan.org/fsw/ff/00index_e.html" target="_blank">http://elm-chan.org/fsw/ff/00index_e.html</a></td><td align="left">FatFs文件系统官网</td></tr><tr><td align="center" rowspan="3">教程书籍</td><td align="left"><a href="STM32开发相关资料/01ARM参考资料/ARM Cortex-M3权威指南(中文).pdf" target="_blank">《ARM Cortex-M3权威指南》</a></td><td alirn="left" rowspan="3">ARM公司专家Joseph Yiu（姚文祥）的力作，中文翻译是NXP的宋岩</td></tr><tr>                                            <td align="left"><a href="STM32开发相关资料/01ARM参考资料/ARM Cortex-M0权威指南(中文).pdf" target="_blank">《ARM Cortex-M0权威指南》</a></td></tr><tr>                                            <td align="left"><a href="" target="_blank">《ARM Cortex-M3与Cortex-M4权威指南》</a></td></tr><tr><td align="center" rowspan="4">开发论坛</td><td align="left"><a href="http://47.111.11.73/forum.php" target="_blank">http://47.111.11.73/forum.php</a></td><td align="left">开源电子网，正点原子的资料下载及问题讨论论坛</td></tr><tr>                                            <td align="left"><a href="https://www.firebbs.cn/forum.php" target="_blank">https://www.firebbs.cn/forum.php</a></td><td align="left">国内Kinetis开发板-野火/秉火（刘火良）主持的论坛，现也做STM32和i.MX RT</td></tr><tr>                                            <td align="left"><a href="https://www.amobbs.com/index.php" target="_blank">https://www.amobbs.com/index.php</a></td><td align="left">阿莫（莫进明）主持的论坛，号称国内最早最火的电子论坛，以交流Atmel AVR系列单片机起家，现已拓展到嵌入式全平台，其STM32系列帖子有70W+。</td></tr><tr>                                            <td align="left"><a href="http://download.100ask.net/index.html" target="_blank">http://download.100ask.net/index.html</a></td><td align="left">韦东山嵌入式资料中心，有些STM32和linux的相关资料也可以来这里找。</td></tr><tr><td align="center" rowspan="3">博客参考</td><td align="left"><a href="http://www.openedv.com/" target="_blank">http://www.openedv.com/</a></td><td align="left">开源网-原子哥个人博客</td></tr><tr>                                            <td align="left"><a href="http://blog.chinaaet.com/jihceng0622" target="_blank">http://blog.chinaaet.com/jihceng0622</a></td><td align="left">博主是原Freescale现NXP的现场应用工程师</td></tr><tr>                                            <td align="left"><a href="https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/cortex-m-resources" target="_blank">cortex-m-resources</a></td><td align="left">这其实并不算是一个博客，这是ARM公司专家Joseph Yiu收集整理的所有对开发者有用的官方Cortex-M资料链接（也包含极少数外部资源链接）</td></tr></table><ul><li>STM32</li></ul><table>    <tr><td align="center" rowspan="2">STM32</td><td align="left"><a href="https://doc.embedfire.com/mcu/stm32/f103/hal_general/zh/latest/index.html" target="_blank">STM32 HAL库开发实战指南——基于F103系列开发板</a></td><td align="left">野火STM32开发教程在线文档</td></tr><tr>                                            <td align="left"><a href="https://doc.embedfire.com/mcu/stm32/f103badao/std/zh/latest/index.html" target="_blank">STM32库开发实战指南——基于野火霸道开发板</a></td><td align="left">野火STM32开发教程在线文档</td></tr></table><ul><li>SD卡</li></ul><table>    <tr><td align="left"><a href="https://www.sdcard.org/" target="_blank">SD Association</a></td><td align="left">提供了SD存储卡和SDIO卡系统规范</td></tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr><td align="left"><a href="https://www.st.com/resource/en/datasheet/stm32f103ze.pdf" target="_blank">STM32F103xx英文数据手册</a></td><td align="left">STM32F103xC/D/E系列的英文数据手册</td></tr>    <tr><td align="left"><a href="https://www.stmcu.com.cn/Designresource/detail/localization_document%20/709978" target="_blank">STM32F103xx中文数据手册</a></td><td align="left">STM32F103xC/D/E系列的中文数据手册</td></tr>    <tr><td align="left"><a href="https://www.st.com/resource/en/reference_manual/rm0008-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf" target="_blank">STM32F10xxx英文参考手册（RM0008）</a></td><td align="left">STM32F10xxx系列的英文参考手册</td></tr>    <tr><td align="left"><a href="https://www.stmcu.com.cn/Designresource/detail/localization_document%20/710001" target="_blank">STM32F10xxx中文参考手册（RM0008）</a></td><td align="left">STM32F10xxx系列的中文参考手册</td></tr>    <tr><td align="left"><a href="https://developer.arm.com/documentation/100165/0201/?lang=en" target="_blank">Arm Cortex-M3 处理器技术参考手册-英文版</a></td><td align="left">Cortex-M3技术参考手册-英文版</td></tr>    <tr><td align="left"><a href="https://www.st.com/resource/en/programming_manual/pm0056-stm32f10xxx20xxx21xxxl1xxxx-cortexm3-programming-manual-stmicroelectronics.pdf" target="_blank">STM32F10xxx Cortex-M3编程手册-英文版(PM0056)</a></td><td align="left">STM32F10xxx/20xxx/21xxx/L1xxxx系列Cortex-M3编程手册-英文版</td></tr>    <tr><td align="left"><a href="https://www.sdcard.org/downloads/pls/" target="_blank">SD卡相关资料——最新版本</a></td><td align="left">有关SD卡的一些资料可以从这里下载</td></tr>    <tr><td align="left"><a href="https://www.sdcard.org/downloads/pls/archives/" target="_blank">SD卡相关资料——历史版本</a></td><td align="left">有关SD卡的一些历史版本资料可以从这里下载，比如后边看的SD卡2.0协议</td></tr>    <tr><td align="left"><a href="./" target="_blank">SD 2.0 协议标准完整版</a></td><td align="left">这是一篇关于SD卡2.0协议的中文文档，还是比较有参考价值的，可以一看</td></tr></table>
              </div>
            </details> 

<h1 id="一、STM32CubeIDE简介"><a href="#一、STM32CubeIDE简介" class="headerlink" title="一、STM32CubeIDE简介"></a><font size=3>一、STM32CubeIDE简介</font></h1><p>偶然看到STM32CubeIDE这个么一个软件，它是ST官方推出的IDE，它已经集成了芯片选型，外设配置，代码生成，代码编译，程序烧录和程序调试等一系列功能，可以说STM32CubeMX是它的其中一个功能而已。这里对这个软件做一个简单的了解。</p>
<h2 id="1-简介"><a href="#1-简介" class="headerlink" title="1. 简介"></a><font size=3>1. 简介</font></h2><p>STM32CubeIDE是一种高级C&#x2F;C++开发平台，具有STM32微控制器和微处理器的外设配置、代码生成、代码编译和调试功能。它基于Eclipse®&#x2F;CDT™框架和用于开发的GCC工具链，以及用于调试的GDB。它支持集成数以百计的现有插件，正是这些插件使Eclipse® IDE的功能趋于完整。</p>
<p>STM32CubeIDE集成了STM32CubeMX的STM32配置与项目创建功能，以便提供一体化工具体验，并节省安装与开发时间。在通过所选板卡或示例选择一个空的STM32 MCU或MPU，或者预配置微控制器或微处理器之后，将创建项目并生成初始化代码。在开发过程的任何时间，用户均可返回外设或中间件的初始化和配置阶段，并重新生成初始化代码，期间不会影响用户代码。</p>
<h2 id="2-特点"><a href="#2-特点" class="headerlink" title="2. 特点"></a><font size=3>2. 特点</font></h2><ul>
<li>通过STM32CubeMX来集成服务：STM32微控制器、微处理器、开发平台和示例项目选择引脚排列、时钟、外设和中间件配置项目创建和初始化代码生成具有增强型STM32Cube扩展包的软件和中间件</li>
<li>基于Eclipse®&#x2F;CDT™，支持Eclipse®插件、GNU C&#x2F;C++ for Arm®工具链和GDB调试器</li>
<li>STM32MP1 系列：支持OpenSTLinux项目：Linux支持Linux</li>
<li>其他高级调试功能包括：CPU内核、外设寄存器和内存视图实时变量查看视图系统分析与实时跟踪(SWV)CPU故障分析工具支持RTOS感知调试，包括Azure</li>
<li>支持ST-LINK（意法半导体）和J-Link (SEGGER)调试探头</li>
<li>从Atollic® TrueSTUDIO®和AC6 System Workbench for STM32 (SW4STM32)导入项目</li>
<li>支持多种操作系统：Windows®、Linux®和macOS®，仅限64位版本</li>
</ul>
<h1 id="二、STM32CubeIDE安装与使用"><a href="#二、STM32CubeIDE安装与使用" class="headerlink" title="二、STM32CubeIDE安装与使用"></a><font size=3>二、STM32CubeIDE安装与使用</font></h1><h2 id="1-Java运行环境"><a href="#1-Java运行环境" class="headerlink" title="1. Java运行环境"></a><font size=3>1. Java运行环境</font></h2><p>安装这个软件之前肯定还是要安装Java运行环境的，可以在官网下载：<a target="_blank" rel="noopener" href="https://www.java.com/zh-CN/download/">Download Java for Windows</a>（尽量安装最新版 64 位的Java），这个下载好后一直默认就可以了，安装完成后如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520072531092.png" alt="image-20230520072531092" style="zoom:50%;" />

<h2 id="2-STM32CubeIDE安装"><a href="#2-STM32CubeIDE安装" class="headerlink" title="2. STM32CubeIDE安装"></a><font size=3>2. STM32CubeIDE安装</font></h2><p>我们来到官网下载安装包：<a target="_blank" rel="noopener" href="https://www.st.com/zh/development-tools/stm32cubeide.html">STM32CubeIDE - STM32的集成开发环境 - 意法半导体STMicroelectronics</a></p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520211605992.png" alt="image-20230520211605992" style="zoom:50%;" />

<p>下载完成后解压安装即可，这个安装挺简单的，可以自己定一个安装路径，然后就是这两个勾选：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520212048180.png" alt="image-20230520212048180" style="zoom:50%;" />

<p>剩下的就是一路默认就可以了，中途可能会弹出安装相关驱动的选项卡，点安装就行了，没什么大问题。一直等待安装完成即可。安装完成后我们双击桌面上的快捷方式打开，会弹出如下界面：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520212454737.png" alt="image-20230520212454737" style="zoom:50%;" />

<p>这是让新建一个工作空间，后边放我们的工程，我们自定义一个目录就可以啦，然后点击Launch就可以啦，启动后界面如下图所示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520212623949.png" alt="image-20230520212623949" style="zoom:50%;" />

<h2 id="3-基本使用"><a href="#3-基本使用" class="headerlink" title="3. 基本使用"></a><font size=3>3. 基本使用</font></h2><h3 id="3-1-STM32CubeIDE创建工程"><a href="#3-1-STM32CubeIDE创建工程" class="headerlink" title="3.1 STM32CubeIDE创建工程"></a><font size=3>3.1 STM32CubeIDE创建工程</font></h3><p>接下来就是使用STM32CubeIDE创建工程啦。如下图所示步骤：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520212853055.png" alt="image-20230520212853055" style="zoom:50%;" />

<p>第一次打开的话可能会下载芯片的一些信息，就会比较慢，等下载安装完成后，会打开如下界面：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520213252022.png" alt="image-20230520213252022" style="zoom:50%;" />

<p>是不是很熟悉，就跟我们的STM32CubeMX一样【③搜索我们的芯片系列】&rarr;【④选中我们的芯片型号】&rarr;【⑤点击下一步】，然后会让我们输入工程的名称：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520213449227.png" alt="image-20230520213449227" style="zoom:50%;" />

<p>在这个界面我们输入工程名字就好啦，其他的可以保持默认就行，然后点击finish即可，然后会弹出这样一个弹窗：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520213554845.png" alt="image-20230520213554845" style="zoom:50%;" />

<p>我们选择Yes就可以啦，然后静静等待工程创建完成就是啦。创建完毕后界面如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520213743159.png" alt="image-20230520213743159" style="zoom:50%;" />

<p>这就没啥好说的了，跟我们的STm32CubeMX界面一毛一样，不过就是多了工程文件管理的一些东西。然后最后生成的工程目录有以下文件夹：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520221846123.png" alt="image-20230520221846123" style="zoom:50%;" />

<h3 id="3-2-配置外设"><a href="#3-2-配置外设" class="headerlink" title="3.2 配置外设"></a><font size=3>3.2 配置外设</font></h3><p>我们可以跟在STM32CubeMX中一样，配置所有的外设，这里就不多余写了，跟STM32CubeMX一模一样。当我们配置完成后，按下Ctrl+s组合键会有如下弹窗，推荐是勾选①，然后点击②Yes，这样下次在我们更新了外设配置的时候再按Ctrl+s就会自动生成代码。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520214308701.png" alt="image-20230520214308701" style="zoom:50%;" />

<p>若是我们选择了no，那么我们后边还可以手动生成代码，在工具栏点击这个图标即可：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520214730034.png" alt="image-20230520214730034" style="zoom:50%;" />

<p>上边那个弹窗选择完毕后，还有一个是关于要不要跳转到C&#x2F;C++编辑界面的选项卡，如下图操作即可，勾选选项，然后点击Yes：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520214656757.png" alt="image-20230520214656757" style="zoom:50%;" />

<p>然后等一会就会跳转到工程代码编辑界面：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520214850663.png" alt="image-20230520214850663" style="zoom:50%;" />

<h3 id="3-3-编译与下载"><a href="#3-3-编译与下载" class="headerlink" title="3.3 编译与下载"></a><font size=3>3.3 编译与下载</font></h3><h4 id="3-3-1-编译工程"><a href="#3-3-1-编译工程" class="headerlink" title="3.3.1 编译工程"></a><font size=3>3.3.1 编译工程</font></h4><p>我们点击工具栏的锤子图标就可编译整个工程：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520215059445.png" alt="image-20230520215059445" style="zoom:50%;" />

<p>编译完成后会有如下提示信息：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520215150914.png" alt="image-20230520215150914" style="zoom:67%;" />

<h4 id="3-3-2-配置调试工具"><a href="#3-3-2-配置调试工具" class="headerlink" title="3.3.2 配置调试工具"></a><font size=3>3.3.2 配置调试工具</font></h4><p>我使用的是Jlink所以就配置为Jlink了，我们点击【①调试】&rarr;【②Debug Configurations】</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520221216688.png" alt="image-20230520221216688" style="zoom:50%;" />

<p>然后回来到调试的配置界面：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520221355783.png" alt="image-20230520221355783" style="zoom:50%;" />

<p>③、这里是我们的工程使用的调试文件；</p>
<p>④、我们选择默认的这个MyFsmc；</p>
<p>⑤、选择调试器选项；</p>
<p>⑥、调试探头选择JLink；</p>
<p>⑦、接口选择SWD或者JTAG</p>
<p>剩下的我都保持默认了，然后选择Apply，然后Close关闭即可。</p>
<h4 id="3-3-3-下载程序"><a href="#3-3-3-下载程序" class="headerlink" title="3.3.3 下载程序"></a><font size=3>3.3.3 下载程序</font></h4><p>我们连接好JLink和开发板，然后点击工具栏的运行按钮：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520215347548.png" alt="image-20230520215347548" style="zoom:50%;" />

<p>首次运行的话会弹出配置窗口：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520215442928.png" alt="image-20230520215442928" style="zoom:50%;" />

<p>我们勾选框中的Enable auto build，这样每次下载的时候，就会自动编译编译工程。但是吧，不习惯，我还是喜欢先编译，确保没错了再下载，看个人喜好啦。然后就会将生成的可执行文件下载到开发板啦，提示信息如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520221655244.png" alt="image-20230520221655244" style="zoom:50%;" />

<h3 id="3-4-导入自己的文件"><a href="#3-4-导入自己的文件" class="headerlink" title="3.4 导入自己的文件"></a><font size=3>3.4 导入自己的文件</font></h3><p>工程中都是默认生成的文件，我们有时候需要添加自己的文件，那么如何导入呢？</p>
<p>（1）将我们要添加的文件添加到工程的顶层目录下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520222313154.png" alt="image-20230520222313154" style="zoom: 50%;" />

<p>（2）【工程名】&rarr;【右键】&rarr;【Refresh】</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520222524117.png" alt="image-20230520222524117" style="zoom:50%;" />

<p>然后我们就会看到我们添加的目录出现在工程中了：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520222642043.png" alt="image-20230520222642043" style="zoom:50%;" />

<p>（3）配置文件路径【工程名】&rarr;【右键】&rarr;【Properties】</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520222831189.png" alt="image-20230520222831189" style="zoom:50%;" />

<p>然后我们就可以来到配置界面，按照下边的标号操作即可。这里包含头文件和源文件，所有会有两个标号③，注意头文件和源文件的路径都需要添加。</p>
<p><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520223649493.png" alt="image-20230520223649493"></p>
<p>不过源文件的添加步骤没有头文件那么多，选择选项卡后直接Add Folder，然后选择文件夹就可以了。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520223917430.png" alt="image-20230520223917430" style="zoom:50%;" />

<p>注意最后要选Apply and Close，这样才能生效。</p>
<h3 id="3-5-新建文件"><a href="#3-5-新建文件" class="headerlink" title="3.5 新建文件"></a><font size=3>3.5 新建文件</font></h3><p>上边是导入文件，那么我们想新建文件呢？</p>
<p>（1）【工程名】&rarr;【右键】&rarr;【New】&rarr;【Head File或者Source File]</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520224327480.png" alt="image-20230520224327480" style="zoom:50%;" />

<p>（2）选择一下源文件要放的目录，以及源文件名和要使用的模板，选择Finish即可，头文件和源文件都是这样。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520224530746.png" alt="image-20230520224530746" style="zoom:50%;" />

<h2 id="4-生成hex文件"><a href="#4-生成hex文件" class="headerlink" title="4. 生成hex文件"></a><font size=3>4. 生成hex文件</font></h2><p>我们编译完成后其实会发现，这个STM32CubeIDE生成和使用的是.elf格式的文件</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521074645330.png" alt="image-20230521074645330" style="zoom:50%;" />

<p>那么我们若是需要hex文件呢？</p>
<p>（1）【Project】&rarr;【Properties】打开工程配置选项卡，或者在这里右键也可以：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521074939885.png" alt="image-20230521074939885" style="zoom:50%;" />

<p>（2）按如下图所示的顺序进行配置</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521075236576.png" alt="image-20230521075236576" style="zoom:50%;" />

<p>然后我们重新编译工程，就会发现在工程目录的Debug目录下生成了对应的bin和hex文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521075448244.png" alt="image-20230521075448244" style="zoom:50%;" />

<h2 id="5-Makefile文件"><a href="#5-Makefile文件" class="headerlink" title="5. Makefile文件"></a><font size=3>5. Makefile文件</font></h2><p>我们其实可以看到在工程创建的时候会直接在工程目录的Debug目录下创建一个Makefile文件，这个文件就是编译整个工程的。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521075654220.png" alt="image-20230521075654220" style="zoom:50%;" />

<p>但是我们似乎不能直接使用make来编译，后边反正试了一下，没什么用，只会清除一下文件，想要使用正常的Makefile文件，还是用STM32CubeMX来生成吧。</p>
<h2 id="6-转成MDK工程？"><a href="#6-转成MDK工程？" class="headerlink" title="6. 转成MDK工程？"></a><font size=3>6. 转成MDK工程？</font></h2><p>我们创建完工程后，在这个地方发现按钮是灰色的，我们无法选择生成的工程类型：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521075749284.png" alt="image-20230521075749284" style="zoom: 33%;" />

<p>有时候想用MDK怎么办呢？不得不承认，人的需求总是在变化，转成MDK的话，在这个IDE软件内是莫得办法的，但是呢，会发现我们创建工程的时候，生成了这样一个文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521075917133.png" alt="image-20230521075917133" style="zoom:50%;" />

<p>这不就是我们之前用STM32CubeMX生成的STM32CubeMX工程嘛，我们双击打开，前提是我们安装得有STM32CubeMX，然后就会使用STM32CubeMX打开一个STM32CubeMX工程，不幸的是，我的版本不一致，报错了：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521080203882.png" alt="image-20230521080203882" style="zoom:50%;" />

<p>后边我就没试了，感觉没必要，后边有需求的话，再转一下看看吧，按理说是可以按这种方式转成MDK工程的。</p>
<h1 id="三、OpenOCD"><a href="#三、OpenOCD" class="headerlink" title="三、OpenOCD"></a><font size=3>三、OpenOCD</font></h1><h2 id="1-简介-1"><a href="#1-简介-1" class="headerlink" title="1. 简介"></a><font size=3>1. 简介</font></h2><p>OpenOCD是用于对STM32进行下载和仿真的工具，需要搭配debug adapter（比如JLink，ST-Link，DAP-Link）和GDB（或Telnet）一起使用，它是一个开源软件包。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521083811134.png" alt="image-20230521083811134" style="zoom:50%;" />



<h2 id="2-下载与安装"><a href="#2-下载与安装" class="headerlink" title="2. 下载与安装"></a><font size=3>2. 下载与安装</font></h2><p>windows版本下载地址是：<a target="_blank" rel="noopener" href="https://gnutoolchains.com/arm-eabi/openocd/">Download OpenOCD for Windows (gnutoolchains.com)</a></p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521082521120.png" alt="image-20230521082521120" style="zoom: 33%;" />

<p>我是选择的最新版本安装，下载完成后发现它是免安装版本，所以可以直接解压后使用，不过我们要添加一下环境变量，将西边的路径添加到环境变量，这里具体过程就不再说了：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\bin</span><br></pre></td></tr></table></figure>

<p>我是直接解压到当前目录了，所以这里就是这个路径，主要是要将 openocd.exe 所在上网目录添加到环境变量，添加完成后，我们在终端执行以下命令看是否可以直接使用openocd.exe软件：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">PS C:\Users\<span class="number">20380</span>&gt; openocd -v</span><br><span class="line">Open On-Chip Debugger <span class="number">0.12</span><span class="number">.0</span> (<span class="number">2023</span><span class="number">-02</span><span class="number">-02</span>) [https:<span class="comment">//github.com/sysprogs/openocd]</span></span><br><span class="line">Licensed under GNU GPL v2</span><br><span class="line">libusb1 <span class="number">09e75</span>e98b4d9ea7909e8837b7a3f00dda4589dc3</span><br><span class="line">For bug reports, read</span><br><span class="line">        http:<span class="comment">//openocd.org/doc/doxygen/bugs.html</span></span><br></pre></td></tr></table></figure>

<h2 id="3-基本使用-1"><a href="#3-基本使用-1" class="headerlink" title="3. 基本使用"></a><font size=3>3. 基本使用</font></h2><h3 id="3-1-连接目标芯片"><a href="#3-1-连接目标芯片" class="headerlink" title="3.1 连接目标芯片"></a><font size=3>3.1 连接目标芯片</font></h3><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">openocd -f &lt;接口配置文件&gt; -f &lt;目标芯片配置文件&gt;</span><br></pre></td></tr></table></figure>

<p>注意：接口配置文件和目标芯片配置文件需要使用绝对路径。</p>
<p>其中接口配置文件是openOCD支持的下载接口，在 openocd安装目录\scripts\interface 文件夹下，目标芯片配置文件是openOCD支持的目标芯片，在 openocd安装目录\scripts\target 文件夹下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521085511731.png" alt="image-20230521085511731" style="zoom:50%;" />

<p>然后我们在终端尝试一下下载程序到我们的开发板：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">openocd -f D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\share\openocd\scripts\interface\jlink.cfg -f D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\share\openocd\scripts\target/stm32f1x.cfg</span><br></pre></td></tr></table></figure>

<p>会发现，报错啦：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">PS C:\Users\<span class="number">20380</span>&gt; openocd -f D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\share\openocd\scripts\interface\jlink.cfg -f D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\share\openocd\scripts\target/stm32f1x.cfg</span><br><span class="line">Open On-Chip Debugger <span class="number">0.12</span><span class="number">.0</span> (<span class="number">2023</span><span class="number">-02</span><span class="number">-02</span>) [https:<span class="comment">//github.com/sysprogs/openocd]</span></span><br><span class="line">Licensed under GNU GPL v2</span><br><span class="line">libusb1 <span class="number">09e75</span>e98b4d9ea7909e8837b7a3f00dda4589dc3</span><br><span class="line">For bug reports, read</span><br><span class="line">        http:<span class="comment">//openocd.org/doc/doxygen/bugs.html</span></span><br><span class="line">Info : <span class="keyword">auto</span>-selecting first available session transport <span class="string">&quot;jtag&quot;</span>. To override use <span class="string">&#x27;transport select &lt;transport&gt;&#x27;</span>.</span><br><span class="line">Info : Listening on port <span class="number">6666</span> <span class="keyword">for</span> tcl connections</span><br><span class="line">Info : Listening on port <span class="number">4444</span> <span class="keyword">for</span> telnet connections</span><br><span class="line">Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED</span><br><span class="line">Warn : Failed to open device: LIBUSB_ERROR_NOT_FOUND</span><br><span class="line">Error: No J-Link device found</span><br></pre></td></tr></table></figure>

<p>这个后边再说怎么解决。当通过后边的操作解决报错后，重新执行命令，会有如下打印：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">PS C:\Users\<span class="number">20380</span>&gt; openocd -f D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\share\openocd\scripts\interface\jlink.cfg -f D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\share\openocd\scripts\target/stm32f1x.cfg</span><br><span class="line">Open On-Chip Debugger <span class="number">0.12</span><span class="number">.0</span> (<span class="number">2023</span><span class="number">-02</span><span class="number">-02</span>) [https:<span class="comment">//github.com/sysprogs/openocd]</span></span><br><span class="line">Licensed under GNU GPL v2</span><br><span class="line">libusb1 <span class="number">09e75</span>e98b4d9ea7909e8837b7a3f00dda4589dc3</span><br><span class="line">For bug reports, read</span><br><span class="line">        http:<span class="comment">//openocd.org/doc/doxygen/bugs.html</span></span><br><span class="line">Info : <span class="keyword">auto</span>-selecting first available session transport <span class="string">&quot;jtag&quot;</span>. To override use <span class="string">&#x27;transport select &lt;transport&gt;&#x27;</span>.</span><br><span class="line">Info : Listening on port <span class="number">6666</span> <span class="keyword">for</span> tcl connections</span><br><span class="line">Info : Listening on port <span class="number">4444</span> <span class="keyword">for</span> telnet connections</span><br><span class="line">Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED</span><br><span class="line">Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED</span><br><span class="line">Info : J-Link V9 compiled May  <span class="number">7</span> <span class="number">2021</span> <span class="number">16</span>:<span class="number">26</span>:<span class="number">12</span></span><br><span class="line">Info : Hardware version: <span class="number">9.20</span></span><br><span class="line">Info : VTarget = <span class="number">3.219</span> V</span><br><span class="line">Info : clock speed <span class="number">1000</span> kHz</span><br><span class="line">Info : JTAG tap: stm32f1x.cpu tap/device found: <span class="number">0x3ba00477</span> (mfg: <span class="number">0x23b</span> (ARM Ltd), part: <span class="number">0xba00</span>, ver: <span class="number">0x3</span>)</span><br><span class="line">Info : JTAG tap: stm32f1x.bs tap/device found: <span class="number">0x06414041</span> (mfg: <span class="number">0x020</span> (STMicroelectronics), part: <span class="number">0x6414</span>, ver: <span class="number">0x0</span>)</span><br><span class="line">Info : [stm32f1x.cpu] Cortex-M3 r1p1 processor detected</span><br><span class="line">Info : [stm32f1x.cpu] target has <span class="number">6</span> breakpoints, <span class="number">4</span> watchpoints</span><br><span class="line">Info : starting gdb server <span class="keyword">for</span> stm32f1x.cpu on <span class="number">3333</span></span><br><span class="line">Info : Listening on port <span class="number">3333</span> <span class="keyword">for</span> gdb connections</span><br></pre></td></tr></table></figure>



<h3 id="3-2-连接＋下载"><a href="#3-2-连接＋下载" class="headerlink" title="3.2 连接＋下载"></a><font size=3>3.2 连接＋下载</font></h3><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">openocd -f &lt;接口配置文件&gt; -f &lt;目标芯片配置文件&gt; -c &lt;要执行的命令&gt;</span><br></pre></td></tr></table></figure>

<p>所以我们可以这样实现一键下载：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 下载bin文件</span></span><br><span class="line">openocd -f D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\share\openocd\scripts\interface\jlink.cfg -f D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\share\openocd\scripts\target/stm32f1x.cfg -c init -c halt -c <span class="string">&quot;flash write_image erase D:/MyLinux/Ubuntu/Sharedfiles/6temp/STM32/MyFSMC/build/debug/build/MyFSMC.bin 0x08000000&quot;</span> -c reset -c shutdown</span><br><span class="line">    </span><br><span class="line"><span class="comment">// 下载hex文件</span></span><br><span class="line">openocd -f D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\share\openocd\scripts\interface\jlink.cfg -f D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\share\openocd\scripts\target/stm32f1x.cfg -c init -c halt -c <span class="string">&quot;flash write_image erase D:/MyLinux/Ubuntu/Sharedfiles/6temp/STM32/MyFSMC/build/debug/build/MyFSMC.hex&quot;</span> -c reset -c shutdown</span><br></pre></td></tr></table></figure>

<p>完成下载后会有如下提示：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">PS C:\Users\<span class="number">20380</span>&gt; openocd -f D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\share\openocd\scripts\interface\jlink.cfg -f D:\BaiduNetdiskDownload\OpenOCD<span class="number">-20230202</span><span class="number">-0.12</span><span class="number">.0</span>\share\openocd\scripts\target/stm32f1x.cfg -c init -c halt -c <span class="string">&quot;flash write_image erase D:/MyLinux/Ubuntu/Sharedfiles/6temp/STM32/MyFSMC/build/debug/build/MyFSMC.bin 0x08000000&quot;</span> -c reset -c shutdown</span><br><span class="line">Open On-Chip Debugger <span class="number">0.12</span><span class="number">.0</span> (<span class="number">2023</span><span class="number">-02</span><span class="number">-02</span>) [https:<span class="comment">//github.com/sysprogs/openocd]</span></span><br><span class="line">Licensed under GNU GPL v2</span><br><span class="line">libusb1 <span class="number">09e75</span>e98b4d9ea7909e8837b7a3f00dda4589dc3</span><br><span class="line">For bug reports, read</span><br><span class="line">        http:<span class="comment">//openocd.org/doc/doxygen/bugs.html</span></span><br><span class="line">Info : <span class="keyword">auto</span>-selecting first available session transport <span class="string">&quot;jtag&quot;</span>. To override use <span class="string">&#x27;transport select &lt;transport&gt;&#x27;</span>.</span><br><span class="line">Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED</span><br><span class="line">Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED</span><br><span class="line">Info : J-Link V9 compiled May  <span class="number">7</span> <span class="number">2021</span> <span class="number">16</span>:<span class="number">26</span>:<span class="number">12</span></span><br><span class="line">Info : Hardware version: <span class="number">9.20</span></span><br><span class="line">Info : VTarget = <span class="number">3.217</span> V</span><br><span class="line">Info : clock speed <span class="number">1000</span> kHz</span><br><span class="line">Info : JTAG tap: stm32f1x.cpu tap/device found: <span class="number">0x3ba00477</span> (mfg: <span class="number">0x23b</span> (ARM Ltd), part: <span class="number">0xba00</span>, ver: <span class="number">0x3</span>)</span><br><span class="line">Info : JTAG tap: stm32f1x.bs tap/device found: <span class="number">0x06414041</span> (mfg: <span class="number">0x020</span> (STMicroelectronics), part: <span class="number">0x6414</span>, ver: <span class="number">0x0</span>)</span><br><span class="line">Info : [stm32f1x.cpu] Cortex-M3 r1p1 processor detected</span><br><span class="line">Info : [stm32f1x.cpu] target has <span class="number">6</span> breakpoints, <span class="number">4</span> watchpoints</span><br><span class="line">Info : starting gdb server <span class="keyword">for</span> stm32f1x.cpu on <span class="number">3333</span></span><br><span class="line">Info : Listening on port <span class="number">3333</span> <span class="keyword">for</span> gdb connections</span><br><span class="line">Warn : [stm32f1x.cpu] target was in unknown state when halt was requested</span><br><span class="line">Info : device id = <span class="number">0x10036414</span></span><br><span class="line">Info : flash size = <span class="number">512</span> KiB</span><br><span class="line">Warn : Adding extra erase range, <span class="number">0x080012c4</span> .. <span class="number">0x080017ff</span></span><br><span class="line"><span class="keyword">auto</span> erase enabled</span><br><span class="line">wrote <span class="number">4804</span> bytes from file D:/MyLinux/Ubuntu/Sharedfiles/<span class="number">6</span>temp/STM32/MyFSMC/build/debug/build/MyFSMC.bin in <span class="number">0.385953</span>s (<span class="number">12.155</span> KiB/s)</span><br><span class="line"></span><br><span class="line">Info : JTAG tap: stm32f1x.cpu tap/device found: <span class="number">0x3ba00477</span> (mfg: <span class="number">0x23b</span> (ARM Ltd), part: <span class="number">0xba00</span>, ver: <span class="number">0x3</span>)</span><br><span class="line">Info : JTAG tap: stm32f1x.bs tap/device found: <span class="number">0x06414041</span> (mfg: <span class="number">0x020</span> (STMicroelectronics), part: <span class="number">0x6414</span>, ver: <span class="number">0x0</span>)</span><br><span class="line">shutdown command invoked</span><br></pre></td></tr></table></figure>



<h2 id="4-报错解决"><a href="#4-报错解决" class="headerlink" title="4. 报错解决"></a><font size=3>4. 报错解决</font></h2><h3 id="4-1-报错原因"><a href="#4-1-报错原因" class="headerlink" title="4.1 报错原因"></a><font size=3>4.1 报错原因</font></h3><p>当我们使用 openocd + j-link 进行烧录和调试时，会接收到这样的警告：Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED，最后发现找不到 j-link：Error: No J-Link device found，尽管我们能使用 j-scope，j-flash 等工具，在 KEIL 中也可以正常识别 j-link 。在 SEGGER 的维基中提到了原因：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">In general, it is possible to use J-Link with OpenOCD. OpenOCD handles J-Link as a dumb JTAG/SWD/… probe and only uses the very low level logic to output JTAG/SWD/… sequences. It does not make use of any high level logic etc. and therefore is much slower than the proprietary SEGGER J-Link DLL / GDBServer / … implementation. In order to use J-Link with OpenOCD the standard J-Link USB driver must be replaced with the WinUSB driver, using <span class="number">3</span>rd party utilities. There are lots of walkthroughs available on the internet.</span><br></pre></td></tr></table></figure>

<p>简单来说就是 openocd 使用 jlink 的方式很低级，所以我们需要把 j-link 原来的驱动更换为 WinUSB 驱动才可以被 openocd 识别。</p>
<p>zadig 和 USBDriverTool 都可以更换驱动，网上绝大部分的教程都推荐使用 zadig，但是其实 USBDriverTool 在这个场景下更适用，原因是 USBDriverTool 不但可以将 j-link usb 驱动转为 WinUSB 驱动，还可以再转换回去，这个是 zadig 做不到的。</p>
<p>SEGGER 的维基中还提到了一点:</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Note: Once the J-Link USB driver has been replaced, no SEGGER software from the J-Link software package will be able to communicate with J-Link anymore. To use SEGGER J-Link software again, the USB driver needs to be switched back to its <span class="keyword">default</span>.</span><br></pre></td></tr></table></figure>

<p>也就是说，我们把 j-link 的驱动转换成 openocd 可以识别的 WinUSB 驱动之后，j-scope，j-flash 等软件都无法使用，也无法在 KEIL 中使用 j-link 烧录和调试程序了。如果想使用这些工具，就必须把驱动还原回去，这时候 USBDriverTool 就派上用场了。看到这里，我还是觉得使用 openocd + j-link 是一种比较低效的方式，如果使用 j-link 作为调试器，那么使用 j-link gdb server 或者强大的 ozone 可能更为合适一些。其实这样还不如直接使用J-Link自带的烧写软件。虽然以后也不用这种方式，但是还是折腾一下，了解一下吧。</p>
<h3 id="4-2-zadig"><a href="#4-2-zadig" class="headerlink" title="4.2 zadig "></a><font size=3>4.2 zadig </font></h3><p>官网在这里：<a target="_blank" rel="noopener" href="https://zadig.akeo.ie/">Zadig - USB driver installation made easy (akeo.ie)</a>，我们可以在直接在这个主页找到下载的地方：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521090941592.png" alt="image-20230521090941592" style="zoom:50%;" />

<p>下载完成后安装即可。</p>
<p>（1）插好 j-link ，并选择【options】&rarr;【List All Devices】</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521091410734.png" alt="image-20230521091410734" style="zoom:41%;" />

<p>（2）找到J-Link设备：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521091600745.png" alt="image-20230521091600745" style="zoom:50%;" />

<p>最后设备选择 j-link ，要更换的驱动选择 WinUSB ，最后点击【Replace Driver】即可完成驱动的替换。值得一提的是，这里可以看到 j-link原来的驱动被识别为 jlink CDC，我们如果要把驱动换回去，就要恢复成现在界面的样子。但是这个软件是做不到的，还是要靠另一款。</p>
<h3 id="4-3-USBDriverTool"><a href="#4-3-USBDriverTool" class="headerlink" title="4.3 USBDriverTool "></a><font size=3>4.3 USBDriverTool </font></h3><p>我后边没用这种方式调试，所以还需要转换回去，这里就是用这个软件啦，我们可以来这里下载：<a target="_blank" rel="noopener" href="https://visualgdb.com/UsbDriverTool/">Automatic USB driver installer for FTDI and LibUSB drivers (visualgdb.com)</a></p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521091952504.png" alt="image-20230521091952504" style="zoom:50%;" />

<p>（1）先插好 j-link 然后在 j-link 设备上单击右键，选择【Install WinUSB】即可完成驱动的转换。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521092120050.png" alt="image-20230521092120050" style="zoom: 67%;" />

<p>（2）转换完成后如下图所示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521092250347.png" alt="image-20230521092250347" style="zoom:50%;" />

<p>这个时候我们看一下MDK，发现现在已经无法识别JLink了：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521093216174.png" alt="image-20230521093216174" style="zoom:33%;" />

<p>（3）如果想要恢复回原来的驱动，【右键】然后选择【Restore default driver】：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521092421567.png" alt="image-20230521092421567" style="zoom:50%;" />



<h1 id="四、VScode插件与使用"><a href="#四、VScode插件与使用" class="headerlink" title="四、VScode插件与使用"></a><font size=3>四、VScode插件与使用</font></h1><h2 id="1-安装插件"><a href="#1-安装插件" class="headerlink" title="1. 安装插件"></a><font size=3>1. 安装插件</font></h2><p>我们需要安装这个ST官方出的VScode插件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520232138219.png" alt="image-20230520232138219" style="zoom:50%;" />

<p>直接点击安装即可，它会附带安装一些其他自己需要的插件，安装完成后在VScode侧边栏会有这样一个图标：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521080438832.png" alt="image-20230521080438832" style="zoom:50%;" />

<p>我们来看一下附带安装了哪些插件，印象中是多了这些，反正都是一起安装的，也没办法选择不安装什么，应该都是有用的吧。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521080700527.png" alt="image-20230521080700527" style="zoom:50%;" />

<p>其中Cortex-Debug是用于调试STM32的插件，CMake是用于配置和管理工程编译的插件。</p>
<h2 id="2-导入工程"><a href="#2-导入工程" class="headerlink" title="2. 导入工程"></a><font size=3>2. 导入工程</font></h2><p>我们点击侧边栏的蝴蝶图标，然后点击Import a local project：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520232606339.png" alt="image-20230520232606339" style="zoom:50%;" />

<p>然后我们选择前边用STM32CubeIDE创建的工程目录下的这个.cproject文件，然后打开，我们会看到直接帮我们生成了一系列的文件用于帮我们分析工程。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520232856040.png" alt="image-20230520232856040" style="zoom:50%;" />

<p>上方有一个让我们选择的选项，但是似乎没选的话一会就调过去了，这个好像是让选择CMake的模式的。然后我们打开主函数所在的main.c文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520233053740.png" alt="image-20230520233053740" style="zoom:50%;" />

<p>会发现里边有大量的报错，我是因为我们没有配置编译器路径以及也没有对CMake进行配置导致的。</p>
<h2 id="3-配置工程"><a href="#3-配置工程" class="headerlink" title="3. 配置工程"></a><font size=3>3. 配置工程</font></h2><h3 id="3-1-编译器路径配置"><a href="#3-1-编译器路径配置" class="headerlink" title="3.1 编译器路径配置"></a><font size=3>3.1 编译器路径配置</font></h3><p>配置编译器路径：【Ctrl+Shift+p】&rarr;【输入C&#x2F;C++】&rarr;【C&#x2F;C++：编辑配置（UI）】&rarr;【我们点击第二个，编辑配置（UI）】就可打开下边的界面啦</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230520234044989.png" alt="image-20230520234044989" style="zoom:50%;" />

<p>这里填交叉编译工具的路径，我们可使用STM32CubeIDE中的交叉编译工具，若是STM32CubeIDE是按默认路径安装，那么这里和填：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">C:\ST\STM32CubeIDE_1<span class="number">.12</span><span class="number">.1</span>\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-<span class="keyword">for</span>-stm32<span class="number">.10</span><span class="number">.3</span><span class="number">-2021.10</span>.win32_1<span class="number">.0</span><span class="number">.200</span><span class="number">.202301161003</span>\tools\bin\arm-none-eabi-gcc.exe</span><br></pre></td></tr></table></figure>

<h3 id="3-2-IntelliSense-模式"><a href="#3-2-IntelliSense-模式" class="headerlink" title="3.2 IntelliSense 模式"></a><font size=3>3.2 IntelliSense 模式</font></h3><p>Ctrl+Shift+p】&rarr;【输入C&#x2F;C++】&rarr;【C&#x2F;C++：编辑配置（UI）】&rarr;【我们点击第二个，编辑配置（UI）】：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521011338146.png" alt="image-20230521011338146" style="zoom:50%;" />



<h3 id="3-3-CMake"><a href="#3-3-CMake" class="headerlink" title="3.3 CMake"></a><font size=3>3.3 CMake</font></h3><p>（1）【CMakeLists.txt】&rarr;【右键】&rarr;【清理所有项目】</p>
<p>（2）【CMakeLists.txt】&rarr;【右键】&rarr;【配置所有项目】&rarr;【Debug】，VSCode上方的信息栏会弹出三个选项，一般选Debug就可以了。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521011033549.png" alt="image-20230521011033549" style="zoom:50%;" />

<p>（3）【CMakeLists.txt】&rarr;【右键】&rarr;【生成所有项目】，然后就会在 build&#x2F;debug&#x2F;build 目录下重新生成elf文件，另外的hex和bin文件也会被更新。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521081811404.png" alt="image-20230521081811404" style="zoom:50%;" />

<h2 id="4-配合OpenOCD一键下载"><a href="#4-配合OpenOCD一键下载" class="headerlink" title="4. 配合OpenOCD一键下载"></a><font size=3>4. 配合OpenOCD一键下载</font></h2><p>我们是导入的工程，并且通过前边的配置，在我们的工程目录下是有一个tasks.json的文件的，里边默认的内容如下：</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;version&quot;</span><span class="punctuation">:</span> <span class="string">&quot;2.0.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;tasks&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">    <span class="punctuation">&#123;</span></span><br><span class="line">      <span class="attr">&quot;label&quot;</span><span class="punctuation">:</span> <span class="string">&quot;Build&quot;</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">&quot;type&quot;</span><span class="punctuation">:</span> <span class="string">&quot;cmake&quot;</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">&quot;command&quot;</span><span class="punctuation">:</span> <span class="string">&quot;build&quot;</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">&quot;problemMatcher&quot;</span><span class="punctuation">:</span> <span class="string">&quot;$gcc&quot;</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">&quot;group&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;kind&quot;</span><span class="punctuation">:</span> <span class="string">&quot;build&quot;</span><span class="punctuation">,</span></span><br><span class="line">        <span class="attr">&quot;isDefault&quot;</span><span class="punctuation">:</span> <span class="literal"><span class="keyword">true</span></span></span><br><span class="line">      <span class="punctuation">&#125;</span></span><br><span class="line">    <span class="punctuation">&#125;</span></span><br><span class="line">  <span class="punctuation">]</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>这是我们使用CMake编译工程的任务，我们把上边的复制一份，然后改成如下的样子：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  <span class="string">&quot;version&quot;</span>: <span class="string">&quot;2.0.0&quot;</span>,</span><br><span class="line">  <span class="string">&quot;tasks&quot;</span>: [</span><br><span class="line">    &#123;</span><br><span class="line">      <span class="string">&quot;label&quot;</span>: <span class="string">&quot;Build&quot;</span>,</span><br><span class="line">      <span class="string">&quot;type&quot;</span>: <span class="string">&quot;cmake&quot;</span>,</span><br><span class="line">      <span class="string">&quot;command&quot;</span>: <span class="string">&quot;build&quot;</span>,</span><br><span class="line">      <span class="string">&quot;problemMatcher&quot;</span>: <span class="string">&quot;$gcc&quot;</span>,</span><br><span class="line">      <span class="string">&quot;group&quot;</span>: &#123;</span><br><span class="line">        <span class="string">&quot;kind&quot;</span>: <span class="string">&quot;build&quot;</span>,</span><br><span class="line">        <span class="string">&quot;isDefault&quot;</span>: <span class="literal">true</span></span><br><span class="line">      &#125;</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      <span class="string">&quot;label&quot;</span>: <span class="string">&quot;OpenOCD下载&quot;</span>,</span><br><span class="line">      <span class="string">&quot;type&quot;</span>: <span class="string">&quot;shell&quot;</span>,</span><br><span class="line">      <span class="string">&quot;command&quot;</span>: <span class="string">&quot;openocd&quot;</span>,</span><br><span class="line">      <span class="string">&quot;args&quot;</span>:[</span><br><span class="line">        <span class="string">&quot;-f&quot;</span>,</span><br><span class="line">        <span class="string">&quot;D:/BaiduNetdiskDownload/OpenOCD-20230202-0.12.0/share/openocd//scripts/interface/jlink.cfg&quot;</span>,</span><br><span class="line">        <span class="string">&quot;-f&quot;</span>,</span><br><span class="line">        <span class="string">&quot;D:/BaiduNetdiskDownload/OpenOCD-20230202-0.12.0/share/openocd/scripts/target/stm32f1x.cfg&quot;</span>,</span><br><span class="line">        <span class="string">&quot;-c&quot;</span>,</span><br><span class="line">        <span class="string">&quot;init&quot;</span>,</span><br><span class="line">        <span class="string">&quot;-c&quot;</span>,</span><br><span class="line">        <span class="string">&quot;halt&quot;</span>,</span><br><span class="line">        <span class="string">&quot;-c&quot;</span>,</span><br><span class="line">        <span class="string">&quot;flash write_image erase D:/MyLinux/Ubuntu/Sharedfiles/6temp/STM32/MyFSMC/build/debug/build/MyFSMC.hex&quot;</span>,</span><br><span class="line">        <span class="string">&quot;-c&quot;</span>,</span><br><span class="line">        <span class="string">&quot;reset&quot;</span>,</span><br><span class="line">        <span class="string">&quot;-c&quot;</span>,</span><br><span class="line">        <span class="string">&quot;shutdown&quot;</span></span><br><span class="line">      ],</span><br><span class="line">      <span class="string">&quot;problemMatcher&quot;</span>: <span class="string">&quot;$gcc&quot;</span>,</span><br><span class="line">      <span class="string">&quot;group&quot;</span>: &#123;</span><br><span class="line">        <span class="string">&quot;kind&quot;</span>: <span class="string">&quot;build&quot;</span>,</span><br><span class="line">        <span class="string">&quot;isDefault&quot;</span>: <span class="literal">true</span></span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>这样，我们按下Ctrl+Shift+p，调出搜索窗口，然后搜索运行，就会出现运行窗口了，后边的话，不用输入关键词，就也会有这个：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521100228974.png" alt="image-20230521100228974" style="zoom:50%;" />

<p>下图就是我们在tasks.json文件中添加的两个任务，我们点击第一个，就会执行对应的下载命令，将代码下载到我们的开发板啦。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-02-STM32CubeIDE/img/image-20230521100255053.png" alt="image-20230521100255053" style="zoom:50%;" />

<h2 id="5-说明"><a href="#5-说明" class="headerlink" title="5. 说明"></a><font size=3>5. 说明</font></h2><p>额，其实并没有想象中那么简单，打开后就能直接用，主要是自己不想折腾了，毕竟keil还是比较方便的，也可以用VSCode开发，然后make编译，jlink下载，这个VSCode+STM32CubeIDE的开发方式暂时我就折腾到这步，只能完成编译和下载，对于调试功能还要配置一系列其他的文件，暂时没去折腾，后边有空了再补充到这里吧。</p>

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/eabbf614.html">LV16-07-开发工具-02-STM32CubeIDE</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2023年06月04日 - 22:06</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/eabbf614.html" title="LV16-07-开发工具-02-STM32CubeIDE">https://sumumm.github.io/post/eabbf614.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/LV16-STM32%E5%BC%80%E5%8F%91/" rel="tag"><i class="fa fa-tag"></i> LV16-STM32开发</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/4e3a140c.html" rel="prev" title="LV16-07-开发工具-03-Makefile文件">
                  <i class="fa fa-angle-left"></i> LV16-07-开发工具-03-Makefile文件
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/daff314e.html" rel="next" title="LV16-07-开发工具-01-STM32CubeMX-Makefile">
                  LV16-07-开发工具-01-STM32CubeMX-Makefile <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
